'use strict';

const Controller = require('egg').Controller;

class ListController extends Controller {
  async index() {
    const {ctx}=this;
    var db =  this.app.mongodb;
    var res =await db.collection("article").find().toArray();
    console.log(ctx.origin+"/public");
    var url =ctx.origin+"/public";
    res.forEach(item=>{
      item.imgSrc=url+item.imgSrc;
      item.avatar=url+item.avatar;
      item.headImgSrc=url+item.headImgSrc;
    })
    ctx.body={
      status:200,
      res
    }
  }
}

module.exports = ListController;
